﻿@model ManufacturerProductModel

@{
	var parentModel = ViewData["Parent"] as ManufacturerModel;
}

<datagrid id="product-manufacturers-grid"
          key-member="Id"
          allow-edit="true"
          allow-resize="true"
          allow-row-selection="true"
          allow-column-reordering="true"
          preserve-grid-state="true"
          max-height="600px"
          onrowclass="productManufacturersGrid_onRowClass">
    <datasource read="@Url.Action("ProductManufacturerList", new { manufacturerId = parentModel.Id })" 
                insert="@Url.Action("ProductManufacturerInsert", new { manufacturerId = parentModel.Id })"
                update="@Url.Action("ProductManufacturerUpdate")"
                delete="@Url.Action("ProductManufacturerDelete")" />
    <paging position="Bottom" show-size-chooser="true" />
    <sorting allow-unsort="true" allow-multisort="false" />
    <toolbar>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.InsertRow" type="button" class="btn btn-primary btn-flat no-anims mr-auto">
                <i class="fa fa-plus"></i>
                <span>@T("Admin.Catalog.Manufacturers.Products.AddNew")</span>
            </button>
            <button datagrid-action="DataGridToolAction.SaveChanges" type="button" class="btn btn-warning no-anims btn-flat">
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.SaveChanges")</span>
            </button>
            <button datagrid-action="DataGridToolAction.CancelEdit" type="button" class="btn btn-light btn-flat mr-auto">
                <span>@T("Common.Cancel")</span>
            </button>
        </toolbar-group>
        <zone name="datagrid_toolbar_alpha"></zone>
        <toolbar-group class="omega"></toolbar-group>
        <zone name="datagrid_toolbar_omega"></zone>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.DeleteSelectedRows" type="button" class="btn btn-danger no-anims btn-flat">
                <i class="far fa-trash-can"></i>
                <span>@T("Admin.Common.Delete.Selected")</span>
            </button>
        </toolbar-group>
    </toolbar>
    <row-commands>
        <a datarow-action="DataRowAction.InlineEdit">@T("Common.Edit")</a>
        <a datarow-action="DataRowAction.Delete">@T("Common.Delete")</a>
    </row-commands>
    <columns>
        <column for="Id" halign="center" visible="false" type="string" readonly="true" />
		<column for="ProductId" width="3fr" hideable="false" entity-member="Product.Name">
            <display-template>
                @Html.LabeledProductName(valueExpression: "item.row.ProductName")
            </display-template>
		</column>
        <column for="Sku" readonly entity-member="Product.Sku" />
        <column for="Published" readonly entity-member="Product.Published" halign="center" />
        <column for="IsFeaturedProduct" halign="center" />
        <column for="DisplayOrder" halign="center" />
    </columns>
</datagrid>

<script sm-target-zone="scripts" data-origin="product-manufacturers-grid">
    function productManufacturersGrid_onRowClass(row) {
        return {
            "text-muted": !row.Published
        };
    }
</script>